# -*- coding: utf-8 -*-
from typing import Optional, List
from pydantic import BaseModel


# =========================== 资料类型字典 ================================

class MaterialTypeCreateRequest(BaseModel):
    """创建资料类型请求"""
    name: str


class MaterialTypeUpdateRequest(BaseModel):
    """更新资料类型请求"""
    name: str


class MaterialTypeResponse(BaseModel):
    """资料类型响应"""
    id: int
    name: str
    create_time: Optional[str] = None
    updated_time: Optional[str] = None


# =========================== 文件来源字典 ================================

class FileSourceCreateRequest(BaseModel):
    """创建文件来源请求"""
    name: str


class FileSourceUpdateRequest(BaseModel):
    """更新文件来源请求"""
    name: str


class FileSourceResponse(BaseModel):
    """文件来源响应"""
    id: int
    name: str
    create_time: Optional[str] = None
    updated_time: Optional[str] = None


# =========================== 资料表 ================================

class MaterialCreateRequest(BaseModel):
    """创建资料请求"""
    file_topic: str
    file_name: str
    company: Optional[str] = None
    file_type: str
    material_type: int
    file_size: Optional[int] = 0
    duration: Optional[int] = 0
    file_source: Optional[int] = None


class MaterialUpdateRequest(BaseModel):
    """更新资料请求"""
    file_topic: Optional[str] = None
    file_name: Optional[str] = None
    company: Optional[str] = None
    file_type: Optional[str] = None
    material_type: Optional[int] = None
    file_size: Optional[int] = None
    duration: Optional[int] = None
    file_source: Optional[int] = None


class MaterialResponse(BaseModel):
    """资料响应"""
    id: int
    file_topic: str
    file_name: str
    company: Optional[str] = None
    file_path: str
    file_type: str
    material_type: int
    file_size: int
    duration: int
    create_time: Optional[str] = None
    updated_time: Optional[str] = None
    is_deleted: bool
    file_source: Optional[int] = None
    file_hash: str
    material_type_name: Optional[str] = None
    file_source_name: Optional[str] = None
    download_url: Optional[str] = None


class MaterialListResponse(BaseModel):
    """资料列表响应"""
    materials: List[MaterialResponse]
    total: int
    page: int
    page_size: int
    total_pages: int


class MaterialQueryRequest(BaseModel):
    """资料查询请求"""
    page: Optional[int] = 1
    page_size: Optional[int] = 10
    file_topic: Optional[str] = None
    company: Optional[str] = None
    material_type: Optional[int] = None
    file_source: Optional[int] = None


class MaterialUploadRequest(BaseModel):
    """资料上传请求"""
    file_topic: str
    company: Optional[str] = None
    material_type: int
    file_source: Optional[int] = None


class MaterialBatchGetRequest(BaseModel):
    """批量获取资料请求"""
    material_ids: List[int]


class MaterialFuzzySearchRequest(BaseModel):
    """资料模糊查询请求"""
    page: Optional[int] = 1
    page_size: Optional[int] = 10
    file_topic: Optional[str] = None
    company: Optional[str] = None
    material_type: Optional[int] = None
    file_source: Optional[int] = None
    search_keyword: Optional[str] = None
